package boardmanage.model.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import boardmanage.dto.RecommendBoardDTO;
import boardmanage.util.BoardUtilities;

public class RecommendBoardDAO {
	
	private SqlMapClientTemplate client;
	public void setSqlMapClientTemplate(SqlMapClientTemplate client){
		this.client = client;
	}
	
	
	public Object insertContent(RecommendBoardDTO bdto) throws SQLException{
		System.out.println("dao : "+bdto);
		return client.insert("recommendBoard.insertContent", bdto);
							 
	}
	public ArrayList<RecommendBoardDTO> selectBoardContentByPage(int page) throws SQLException{
		HashMap map = new HashMap();
		map.put("contentPerPage", BoardUtilities.CONTENT_PER_PAGE);
		map.put("page", page);
		return (ArrayList<RecommendBoardDTO>)client.queryForList("recommendBoard.selectBoardListByPage", map);
	}
	public int selectTotalContent() throws SQLException{
		
		return (Integer)client.queryForObject("recommendBoard.selectTotalContent");
	}
	
	
	public RecommendBoardDTO selectContentByNo(int no) throws SQLException {
		return (RecommendBoardDTO)client.queryForObject("recommendBoard.selectContentByNo", no);
	}
	
	
	public void updateViewCount(int no) throws SQLException {
		client.update("recommendBoard.updateViewCount", no);
	}
	
	
	public void deleteContentByNo(int no) throws SQLException {
		client.delete("recommendBoard.deleteContentByNo", no);
	}
	
	public void updateContent(RecommendBoardDTO bdto) throws SQLException {
		client.update("recommendBoard.updateContent", bdto);
	}
	
	public void updateAccept(Map map) throws SQLException{
		client.update("recommendBoard.updateAccept", map);
	}
}
